import Pay from '../../utils/pay'
Page({
  data: {
    money: null,
  },

  onLoad(options) {},
  _getValue({ detail }) {
    this.setData({
      money: detail,
    })
  },
  async _submit() {
    const { money } = this.data
    if (!money)
      return wx.showToast({
        title: '请输入金额',
        icon: 'none',
        duration: 2000,
      })
    let { code, data } = await wx.requestAsync({
      url: '/recharge',
      data: { money: money * 100 },
    })
    if (code == 0) {
      let flag = await Pay({ ...data }, data)
      if (flag) {
        wx.navigateBack({
          delta: 1,
        })
      }
    }
  },
})
